
import 'dart:html';
import 'dart:typed_data';

import 'package:json_annotation/json_annotation.dart';
import 'package:my_flutter_test/models/briefItems.dart';
import 'package:my_flutter_test/models/utils.dart';

part 'itemInfo.g.dart';
@JsonSerializable(explicitToJson: true)
class ItemInfo{
  @JsonKey(toJson:bytes2base64,fromJson: base2bytes)
  Uint8List img;
  String name;
  String price;
  int id;
  String ownerName;
  String description;
  List<Comment> comments;


  ItemInfo(this.img, this.name, this.price, this.id, this.ownerName,
      this.description, this.comments);

  factory ItemInfo.fromJson(Map<String, dynamic> json) => _$ItemInfoFromJson(json);

  Map<String, dynamic> toJson() => _$ItemInfoToJson(this);
}

@JsonSerializable(explicitToJson: true)
class Comment{
  @JsonKey(toJson:bytes2base64,fromJson: base2bytes)
  Uint8List userImg;
  String userName;
  String content;


  factory Comment.fromJson(Map<String, dynamic> json) => _$CommentFromJson(json);

  Comment(this.userName, this.content, this.userImg);

  Map<String, dynamic> toJson() => _$CommentToJson(this);
}